package com.lm.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.aliyun.openservices.ons.api.Message;
import com.aliyun.openservices.ons.api.bean.ProducerBean;
import com.lm.service.ReceiveService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * LmUser服务实现层
 *
 * @author Mao
 * @create Sat May 05 16:29:17 CST 2018
 */
@Service
public class ReceiveServiceImpl implements ReceiveService {

    private static final Logger logger = LoggerFactory.getLogger(ReceiveServiceImpl.class);

    @Autowired
    private ProducerBean producer;

    @Value("${producter.topic.kwd.product}")
    private String topicKwdProduct;
    @Value("${Tag.product.add}")
    private String tagProductAdd;

    /**
     * 数据发送到秒单之家
     */
    public void sendMDZJ(JSONObject userInfoJson, int userId) {
        Message message = new Message();
        message.setTopic(topicKwdProduct);
        message.setTag(tagProductAdd);
        message.setBody(userInfoJson.toJSONString().getBytes());
        message.setKey("midas" + userId);
        producer.send(message);
        logger.info("sendRocketMQ message :{}", message);
    }
}
